import { BASE_URL } from '../../../http/config';

Page({
  data: {
    detail: null,
    id: null
  },

  onLoad(options) {
    if (options && options.id) {
      this.setData({ id: options.id });
      this.getDetail(options.id);
    }
  },

  getDetail(id) {
    wx.request({
      url: `${BASE_URL}/psychologyKnowledge/findById/${id}`, // 假设接口为findById
      data: {  },
      success: (res) => {
        if (res.data.code === 200) {
          this.setData({ detail: res.data.data });
        } else {
          wx.showToast({
            title: res.data.message || '加载失败',
            icon: 'none'
          });
        }
      },
      fail: () => {
        wx.showToast({
          title: '网络请求失败',
          icon: 'none'
        });
      }
    });
  }
});